package com.qdu.web.controller.bussiness;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.qdu.common.annotation.Log;
import com.qdu.common.core.controller.BaseController;
import com.qdu.common.core.domain.AjaxResult;
import com.qdu.common.enums.BusinessType;
import com.qdu.bussiness.domain.BusHire;
import com.qdu.bussiness.service.IBusHireService;
import com.qdu.common.utils.poi.ExcelUtil;
import com.qdu.common.core.page.TableDataInfo;

/**
 * 雇佣记录Controller
 * 
 * @author qdu
 * @date 2022-03-11
 */
@RestController
@RequestMapping("/bussiness/hire")
public class BusHireController extends BaseController
{
    @Autowired
    private IBusHireService busHireService;

    /**
     * 查询雇佣记录列表
     */
    @PreAuthorize("@ss.hasPermi('bussiness:hire:list')")
    @GetMapping("/list")
    public TableDataInfo list(BusHire busHire)
    {
        startPage();
        List<BusHire> list = busHireService.selectBusHireList(busHire);
        return getDataTable(list);
    }

    /**
     * 导出雇佣记录列表
     */
    @PreAuthorize("@ss.hasPermi('bussiness:hire:export')")
    @Log(title = "雇佣记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BusHire busHire)
    {
        List<BusHire> list = busHireService.selectBusHireList(busHire);
        ExcelUtil<BusHire> util = new ExcelUtil<BusHire>(BusHire.class);
        util.exportExcel(response, list, "雇佣记录数据");
    }

    /**
     * 获取雇佣记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('bussiness:hire:query')")
    @GetMapping(value = "/{hireId}")
    public AjaxResult getInfo(@PathVariable("hireId") Long hireId)
    {
        return AjaxResult.success(busHireService.selectBusHireByHireId(hireId));
    }

    /**
     * 新增雇佣记录
     */
    @PreAuthorize("@ss.hasPermi('bussiness:hire:add')")
    @Log(title = "雇佣记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BusHire busHire)
    {
        return busHireService.insertBusHire(busHire);
    }

    /**
     * 修改雇佣记录
     */
    @PreAuthorize("@ss.hasPermi('bussiness:hire:edit')")
    @Log(title = "雇佣记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BusHire busHire)
    {
        return toAjax(busHireService.updateBusHire(busHire));
    }

    /**
     * 删除雇佣记录
     */
    @PreAuthorize("@ss.hasPermi('bussiness:hire:remove')")
    @Log(title = "雇佣记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{hireIds}")
    public AjaxResult remove(@PathVariable Long[] hireIds)
    {
        return toAjax(busHireService.deleteBusHireByHireIds(hireIds));
    }
}
